home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 1.9 KB | 96 lines | [TEXT/MPCC] |
- // ScreenTarget.cpp
-
-
- #include "ScreenTarget.h"
- #include <QDOffscreen.h>
-
-
- ScreenTarget::ScreenTarget(
- WindowPtr window)
- {
- UpdateFromWindow(window);
- }
-
-
- ScreenTarget::~ScreenTarget()
- {
- }
-
-
- void
- ScreenTarget::UpdateFromWindow(
- WindowPtr window)
- {
- Rect globalRect = window->portRect;
- GrafPtr savePort;
- GetPort(&savePort);
- SetPort(window);
- LocalToGlobal(&topLeft(globalRect));
- LocalToGlobal(&botRight(globalRect));
- GDHandle theDevice = GetMaxDevice(&globalRect);
- PixMapHandle thePixMap = (*theDevice)->gdPMap;
-
- char *tba = GetPixBaseAddr(thePixMap);
- rowBytes = (*thePixMap)->rowBytes&0x3fff;
- int indenth = 8 - (globalRect.left&7); // ensure double alignment
- tba += indenth+globalRect.left;
- tba += globalRect.top*rowBytes;
- width = ((globalRect.right-globalRect.left-indenth)&~7)/2;
- height = (globalRect.bottom-globalRect.top)/2;
- addRowBytes = rowBytes-(width*2);
- baseAddr = tba;
- SetPort(savePort);
- }
-
-
- void
- ScreenTarget::PutData(
- const void *inPtr,
- long inRowBytes,
- long inWidth,
- long inNumRows,
- long destRow,
- long destCol)
- {
- const int cAddRowBytes = (inRowBytes-inWidth)>>2; // in longs
- const long *srcPtr = (long *)inPtr;
- const int cWidth = inWidth>>2; // num longs
-
- const int dAddRowBytes = (rowBytes+addRowBytes)>>3; // in doubles, two scan lines
- double *dstPtr = (double *)baseAddr;
- double *dstPtr2 = ((double*)dstPtr)+(rowBytes>>3);
- double dBuf;
- double *dBufP = 1+&dBuf;
-
- int h = inNumRows;
-
- srcPtr--; // adjust for pre-increment
- dstPtr--;
- dstPtr2--;
-
- while (--h >= 0) {
- int v = cWidth;
- while (--v >= 0) {
- long l = *++srcPtr;
- char *d = (char *)dBufP;
- long l2 = l >> 8;
- *--d = l;
- *--d = l;
- long l3 = l >> 16;
- *--d = l2;
- *--d = l2;
- long l4 = l >> 24;
- *--d = l3;
- *--d = l3;
- *--d = l4;
- *--d = l4;
- double dd = dBuf;
- *++dstPtr = dd;
- *++dstPtr2 = dd;
- }
- dstPtr += dAddRowBytes;
- srcPtr += cAddRowBytes;
- }
- }
-
-